package com.powerbosframework.jdbc.core;
import java.sql.SQLException;

import com.powerbosframework.jdbc.core.JdbcTmplt;
import com.powerbosframework.jdbc.core.JdbcTmpltManager;
import com.powerbosframework.jdbc.datasource.JDBCDataSource;
import com.powerbosframework.jdbc.core.JdbcSession;
import com.powerbosframework.log.LogFactory;
import com.powerbosframework.log.Logger;

/**
 * JDBC会话工厂类
 * @author youfu.wang
 * @version 1.0
 */
public class JdbcSessionFactory implements JdbcSession{
	private JDBCDataSource dataSource;
	private static Logger log=LogFactory.getInstance();
	
	public JdbcSessionFactory(){
		
	}
	public JdbcSessionFactory(JDBCDataSource dataSource){
		this.dataSource = dataSource;
	}
	public JDBCDataSource getDataSource() {
		return dataSource;
	}

	public void setDataSource(JDBCDataSource dataSource) {
		this.dataSource = dataSource;
	}

	public JdbcTmplt getJdbcTmplt(){					
		JdbcTmplt jdbcTmplt=new JdbcTmpltManager(dataSource);
		return jdbcTmplt;
	}
	public void close() throws SQLException{
		if (dataSource != null) {
			dataSource.close();
		}		
	}
}
